/*
 * Copyright (C) 2010-2012 Susanta Tewari
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package coalescent.nb.jobs1;

import cef.command.Command;
import cef.command.Model_MLE_Command;
import cef.pui.EventConstructionException;
import coalescent.cef.command.MLE_KC64ThetaCommand;
import coalescent.cef.command.listener.KC64_MLE_OLs;
import coalescent.cef.pui.KC64_MLE_EventImpl;
import coalescent.cef.pui.MLE_KC64ThetaEventImpl;
import coalescent.nb.jobs.properties.ComboPropertys_Coa;
import coalescent.nb.jobs.properties.Propertys_Coa;
import commons.nb.jobs.Job;
import commons.nb.jobs.gui.JobsGUIUtil;
import commons.nb.jobs.properties.ComboPropertyImpl;

import java.util.Properties;

/**
 * @since 1.4.0
 * @version version
 * @author Susanta Tewari
 * @history Created on Dec 18, 2012.
 */
public final class MLE_KC64ThetaJob extends Job<KC64_MLE_EventImpl> {

    public MLE_KC64ThetaJob() {

        setName("mle-kc64-theta");
        setDisplayName("<b>MLE-Infinite-Alleles (KC64)</b>");
        setShortDescription("Computes MLE for Infinite-Alleles (KC64) Model");


        // data
        addComboProperty(ComboPropertys_Coa.KC64_DATA(true, "coalescent.builder.KC64Data"));


        // theta-range
        addComboProperty(ComboPropertys_Coa.KC64List("coalescent.builder.KC64List.theta"));


        // lhood-algo
        addComboProperty(
            new ComboPropertyImpl(
                Propertys_Coa.KC64_LHood_Algo("coalescent.builder.KC64MultiLHood")));


        // listeners
        addCommandOutputListener(new KC64_MLE_OLs.PW());
        addCommandOutputListener(JobsGUIUtil.makeEmbeddable(new KC64_MLE_OLs.OC()));
    }

    @Override
    public Properties getProperties() {

        final Properties props = super.getProperties();

        props.setProperty("coalescent.builder.KC64MultiLHood.implCode", "exact-recursion-multi");

        return props;
    }

    @Override
    public boolean isCancellable() {
        return MLE_KC64ThetaCommand.isCancellable();
    }

    @Override
    protected KC64_MLE_EventImpl createEvent() throws EventConstructionException {
        return new KC64_MLE_EventImpl(getProperties());
    }

    @Override
    public Class<MLE_KC64ThetaEventImpl> getEventImplType() {
        return MLE_KC64ThetaEventImpl.class;
    }

    @Override
    protected Command createCommand(final KC64_MLE_EventImpl event) {
        return new Model_MLE_Command<>(event);
    }
}
